package com.usian.service.Impl;

import com.usian.controller.UserController;
import com.usian.mapper.UsersMapper;
import com.usian.pojo.User;
import com.usian.service.UserService;
import org.apache.ibatis.annotations.Param;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
    public class UserServiceImpl implements UserService {
    private static final Logger LOGGER= LoggerFactory.getLogger(UserServiceImpl.class);


    @Autowired
    private UsersMapper usersMapper;

    @Override
    public List<User> findAll() {
        LOGGER.info("111111111");
        return usersMapper.selectList(null);
    }

    @Override
    public User findById(Integer id) {
//        return usersMapper.selectByPrimaryKey(id);
        return usersMapper.selectById(id);
    }



    @Override
    public void insertUser(User user) {
//        usersMapper.insertSelective(user);
    usersMapper.insert(user);
    }

    @Override
    public void delUser(Integer userId) {
//        usersMapper.deleteByPrimaryKey(userId);
        usersMapper.deleteById(userId);
    }

    @Override
    public void updateUser(User user) {
        usersMapper.updateById(user);
    }

    @Override
    public User login(User user) {
        return usersMapper.login(user);
    }


}
